using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class ItemStockMap : EntityTypeConfiguration<ItemStock>
	{
		public ItemStockMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.ItemCode)
				.HasMaxLength(10);
				
			this.Property(t => t.Maufacture)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("ItemStocks");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.ItemCode).HasColumnName("ItemCode");
			this.Property(t => t.Qty).HasColumnName("Qty");
			this.Property(t => t.MinLevel).HasColumnName("MinLevel");
			this.Property(t => t.MaxLevel).HasColumnName("MaxLevel");
			this.Property(t => t.UnitOfMeasurementType).HasColumnName("UnitOfMeasurementType");
			this.Property(t => t.ItemType).HasColumnName("ItemType");
			this.Property(t => t.FormId).HasColumnName("FormId");
			this.Property(t => t.Maufacture).HasColumnName("Maufacture");
			this.Property(t => t.SiteId).HasColumnName("SiteId");
			this.Property(t => t.LocationId).HasColumnName("LocationId");
			this.Property(t => t.BasedPriceType).HasColumnName("BasedPriceType");
			this.Property(t => t.BasedPrice).HasColumnName("BasedPrice");
			this.Property(t => t.ChargeAble).HasColumnName("ChargeAble");

			// Relationships
			this.HasOptional(t => t.ItemForm)
				.WithMany(t => t.ItemStocks)
				.HasForeignKey(d => d.FormId);
				
		}
	}
}

